
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>表单</title>
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css">
    <link rel="stylesheet" href="__PUBLIC__/static/css/style.css">
    <link rel="icon" href="__PUBLIC__/static/image/code.png">
</head>
<body class="body">

<form class="layui-form" action="" method="post" id="addform">

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">角色名称</label>
            <div class="layui-input-inline">
                <input type="type" name="title" lay-verify="title" autocomplete="off" placeholder="请输入角色名称" class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">角色图标</label>
        <div class="layui-input-inline">
            <input type="type" name="icon" lay-verify="" autocomplete="off" placeholder="请输入角色图标" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">角色描述</label>
            <div class="layui-input-inline">
                <input type="type" name="notation" lay-verify="" autocomplete="off" placeholder="请输入角色描述" class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
	  	<div class="layui-inline">
	    <label class="layui-form-label">状态</label>
	    <div class="layui-input-inline">
	      <input type="radio" name="status" value="1" title="正常" checked="">
	      <input type="radio" name="status" value="0" title="禁止">
	    </div>
    </div>
    
<style type="text/css">
#auth-tree{}
#auth-tree ul .auth-t0{margin-left:0px;width:800px;overflow:hidden;}
#auth-tree ul .auth-t0 ul li.auth-t1{margin-left:40px;width:800px;overflow:hidden;}
#auth-tree ul .auth-t0 ul li.auth-t1 ul{margin-left:40px;}
#auth-tree ul .auth-t0 ul li.auth-t1 ul li.auth-t2{margin-left:10px;float:left;overflow:hidden;}
#auth-tree ul{}
</style>

    <div class="layui-form-item">
	  	<div class="layui-inline">
	    <label class="layui-form-label">权限</label>
	    <div class="layui-input-inline" id="auth-tree">
	    	{$data|getTree=0|raw}
	    </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<!-- 通用-970*90 -->
<script src="__PUBLIC__/layui/layui.js" charset="utf-8"></script>
<script src="__ADMIN__/js/comm.js" charset="utf-8"></script>
<script>
    layui.use(['jquery', 'form', 'upload', 'laydate'], function(){
        var form = layui.form
                ,layer = layui.layer
                ,upload = layui.upload
                ,$ = layui.$ //重点处

        //自定义验证规则
        form.verify({
            title: function(value){
               // if(value.length < 2){
                    //return '标题至少得2个字符啊';
               // }
            }
        });

form.on('checkbox(formauth)',function(data) {
    if(data.elem.checked){
        console.log(data.elem.parentNode.parentNode.parentNode);
    }
   // console.log(data.elem.value);
});


        //监听指定开关
      form.on('submit(demo1)', function(data) {
        $.post('{:url('admin/AuthGroup/add')}', $('#addform').serialize(),
          function(data) {
            if (data.code == 1) {
              layer.alert(data.msg, {
                skin: 'layui-layer-molv' //样式类名
                  ,
                closeBtn: 0
              }, function() {
                location.href = data.url;
              });
            } else {
              layer.msg(data.msg);
            }
          });
        return false;
      });


    });
</script>
</body>
</html>